import { faker } from '@faker-js/faker/.';
import { EventTypeEnum } from 'src/common/constant/enums';
import { EventToPlayer } from 'src/modules/event-to-player/entities/event-to-player.entity';

export const generateEventToPlayerMock = (
  override?: Partial<EventToPlayer>,
): EventToPlayer => {
  return {
    id: override?.id ?? faker.number.int(),
    eventId: override?.eventId ?? faker.number.int(),
    event: override?.event ?? undefined,
    player: override?.player ?? null,
    player2: override?.player2 ?? null,
    registrationIndex:
      override?.registrationIndex ?? faker.string.alphanumeric(),
    // team: override?.team ?? null,
    subTeamMatchType:
      override?.subTeamMatchType ?? faker.helpers.enumValue(EventTypeEnum),
    player1Name: override?.player1Name ?? faker.person.fullName(),
    player2Name: override?.player2Name ?? faker.person.fullName(),
    teamName: override?.teamName ?? faker.company.name(),
    stageOrderInEvent: override?.stageOrderInEvent ?? faker.number.int(),
    isByePlayer: override?.isByePlayer ?? faker.datatype.boolean(),
    copyFromId: override?.copyFromId ?? faker.number.int(),
  };
};

export const generateEventToPlayerMocks = (
  count: number,
  overrides?: Partial<EventToPlayer>[],
): EventToPlayer[] => {
  return Array.from({ length: count }, (_, index) =>
    generateEventToPlayerMock(overrides?.[index]),
  );
};
